<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增校区')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-campus-add">
           <!-- <div class="form-group" th:if="${@permission.hasPermi('system:superAdmin:opt')} != 'hidden'">
                <label class="col-sm-3 control-label">请选择租户：</label>
                <div class="col-sm-8">
                    <select name="tenantId" id="tenantId"  class="form-control">
                        <option th:each="t : ${tenantList}" th:text="${t.tenantName}" th:value="${t.tenantId}"></option>
                    </select>
                </div>
            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">校区名称：</label>
                <div class="col-sm-8">
                    <input  id="name" name="name" class="form-control" type="text" required maxlength="30"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">联系电话：</label>
                <div class="col-sm-8">
                    <input  id="phone" name="phone" class="form-control" type="text" required maxlength="30"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">校区地址：</label>
                <div class="col-sm-8" id="distpicker1">
                    <div class="col-sm-4">
                        <select class="form-control" name="province"></select>
                    </div>
                    <div class="col-sm-4">
                        <select class="form-control" name="city" ></select>
                    </div>
                    <div class="col-sm-4">
                        <select class="form-control" name="area" > </select>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">&nbsp;</label>
                <div class="col-sm-8">
                    <input id="address" name="address" class="form-control" type="text" placeholder="请输入详细地址" required/>
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">负责人：</label>
                <div class="col-sm-8">
                    <input id="major" name="major" class="form-control" type="text" required/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">校区介绍：</label>
                <div class="col-sm-8">
                    <textarea id="introduce" name="introduce" class="form-control" maxlength="300"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: distpicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "system/campus"
        $("#form-campus-add").validate({
            onkeyup: false,
            rules:{
                name:{
                    remote: {
                        url: ctx + "system/campus/checkNameUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "name" : function() {
                                return $.common.trim($("#name").val());
                            },
                            "tenantId" : function() {
                                return $.common.trim($("#tenantId").val());
                            }
                        },
                        dataFilter: function(data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
                orderNum:{
                    digits:true
                },
            },
            messages: {
                "name": {
                    remote: "名称已存在！"
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-campus-add').serialize());
            }
        }

        $(function(){
            $("#distpicker1").distpicker();
        })
    </script>
</body>
</html>